const Router = require('koa-router')
const router = new Router()
const callCloudDB = require('../utils/callCloudDB.js')

router.get('/list', async (ctx, next) => {
    const query = `
        db.collection('show').orderBy('createTime', 'desc').get()
    `
    const res = await callCloudDB(ctx, 'databasequery', query)
    ctx.body = {
        code: 20000,
        data: res.data
    }
})

//删除操作
router.get("/del", async (ctx, next) => {
    const params = ctx.request.query;
    const query = `db.collection('show').doc('${params._id}').remove()`;
    const res = await callCloudDB(ctx, "databasedelete", query);
    ctx.body = {
        code: 20000,
        data: res,
    };
});


module.exports = router
